local CarTool=_G.CommonOHOH.load.CarTool();
local M={}

function M.GetAllCarIdBySkinData(data)
    local bodyId, flagId, ringId, tailId, weaponId = nil, nil, nil, nil, nil
    for carId,status in pairs(data) do
        local type = CarTool.GetPartCfgData(carId).type
        if type == 1 then
            weaponId = carId
        elseif type == 2 then
            ringId = carId
        elseif type == 3 then   
            bodyId = carId
        elseif type == 4 then
            tailId = carId
        elseif type == 5 then 
            flagId = carId
        end
    end
    return bodyId,flagId,ringId,tailId,weaponId
end
function M.IsSkinDataSame(data1,data2)
    -- 获取两个数据对应的各个部分的 Id
    local bodyId1, flagId1, ringId1, tailId1, weaponId1 = M.GetAllCarIdBySkinData(data1)
    local bodyId2, flagId2, ringId2, tailId2, weaponId2 = M.GetAllCarIdBySkinData(data2)

    -- 比较每个部分的 Id 是否相同
    return bodyId1 == bodyId2 and 
           flagId1 == flagId2 and 
           ringId1 == ringId2 and 
           tailId1 == tailId2 and 
           weaponId1 == weaponId2
end


function M.GetAllCarIdByEquipData(data)
    local bodyId, flagId, ringId, tailId, weaponId = nil, nil, nil, nil, nil
    for i = 1, #data do
        local type = CarTool.GetPartCfgData(data[i]).type
        if type == 1 then
            weaponId = data[i]
        elseif type == 2 then
            ringId = data[i]
        elseif type == 3 then   
            bodyId = data[i]
        elseif type == 4 then
            tailId = data[i]
        elseif type == 5 then 
            flagId = data[i] 
        end
    end
    return bodyId,flagId,ringId,tailId,weaponId
end
function M.IsEquipSame(data1,data2)
    -- 获取两个数据对应的各个部分的 Id
    local bodyId1, flagId1, ringId1, tailId1, weaponId1 = M.GetAllCarIdByEquipData(data1)
    local bodyId2, flagId2, ringId2, tailId2, weaponId2 = M.GetAllCarIdByEquipData(data2)

    -- 比较每个部分的 Id 是否相同
    return bodyId1 == bodyId2 and 
           flagId1 == flagId2 and 
           ringId1 == ringId2 and 
           tailId1 == tailId2 and 
           weaponId1 == weaponId2
end
return M